import fetch from 'utils/fetch'
// import { fail } from 'assert';
// import { param } from '../utils/index'

export default {
  addSchool (data, options) { // 保存修改校区
    return fetch({
      url: '/train/school/saveTrainSchoolInfo',
      method: 'POST',
      data: JSON.stringify(data),
      options
    })
  },
  deleteSchool (data, options) { // 删除校区
    return fetch({
      url: '/train/school/removeTrainSchool',
      method: 'POST',
      data,
      options
    })
  },
  schoolList (params) { // 校区列表
    let url = '/train/school/trainSchoolPageInfo'
    return fetch({
      url: url,
      params
    })
  },
  getScheduleList (params) { // 课程表
    return fetch({
      url: 'train/course/schedule/list',
      params
    })
  },
  getListCurrculum (params) { // 获取课程列表
    return fetch({
      url: '/train/course/trainCoursePageInfo',
      params
    })
  },
  trainCourseDetail (params) { // 查询课程详情&校区
    return fetch({
      url: '/train/course/trainCourseDetail',
      params
    })
  },
  listTrainClassLevelInfo (params) { // 获取班别
    return fetch({
      url: '/train/course/listTrainClassLevelInfo',
      params
    })
  },
  timeCourseInfo (params) {
    return fetch({
      url: '/train/course/timeCourseInfo',
      params
    })
  },
  listStartClassTimeInfo (params) { // 获取上课时间段
    return fetch({
      url: '/train/course/ListStartClassTimeInfo',
      params
    })
  },
  listTrainClassInfo (params) { // 查询班级列表
    return fetch({
      url: '/train/course/listTrainClassInfo',
      params
    })
  },
  trainClassInfo (params) { // 获取班级详细信息
    return fetch({
      url: '/train/course/trainClassDetailById',
      params
    })
  },
  checkTeacher (params) { // 检查同一时间段，教练是否重复
    return fetch({
      url: '/train/classroom/isDuplicate',
      params
    })
  },
  classEdit (params) { // 编辑班级获取班级详情
    return fetch({
      url: '/train/classroom/to/change',
      params
    })
  },
  editScheme (data, type) { // 编辑教学计划
    return fetch({
      url: '/train/teach/scheme',
      method: type,
      data
    })
  },
  getScheme (params) { // 获取教学计划
    return fetch({
      url: '/train/teach/scheme/classid',
      params
    })
  },
  getDrillInfo (params) { // 获取教学计划
    return fetch({
      url: '/train/class/drill/info',
      params
    })
  },
  saveDrillInfo (data, options = {}) {
    let method = options.type || (data.id ? 'PUT' : 'POST')
    return fetch({
      url: '/train/class/drill',
      method,
      data,
      options
    })
  },
  getDrillplanInfo (params) {
    return fetch({
      url: '/train/schedule/drillplan/info',
      params
    })
  },
  getSchemeClasslist (params) { // 获取班级课时列表
    return fetch({
      url: '/train/classroom/schedule',
      params
    })
  },
  getScheduleid (params) { // 获取教学信息
    return fetch({
      url: '/train/teach/v2/info/scheduleid',
      params
    })
  },
  editInformation (data, type) { // 编辑教学信息
    return fetch({
      url: '/train/teach/v2/info',
      method: type,
      data
    })
  },
  getAllProcess (params) {
    return fetch({ // 查询所有教学过程信息
      url: '/train/teach/v2/process/classscheduleid',
      params
    })
  },
  getProcess (data, type) { // 查询单条教学过程信息
    return fetch({
      url: '/train/teach/v2/process/',
      method: type,
      data
    })
  },
  editProcess (params, type) { // 编辑单条教学过程信息
    return fetch({
      url: '/train/teach/v2/process/',
      method: type,
      params
    })
  },
  classStudentInfo (params) { // 根据班级ID查询班级学员
    return fetch({
      url: '/train/student/class/classStudentInfo',
      params
    })
  },
  getSchoolList (params) { // 根据课程id获取校区列表
    return fetch({
      url: '/train/course/school/list',
      params
    })
  },
  getClasstypeList (params) { // 根据课程id获取班别列表
    return fetch({
      url: '/train/course/classes/list',
      params
    })
  },
  listPageInfo  (params) { // 获取班级列表
    return fetch({
      url: '/train/classroom/listPageInfo',
      params
    })
  },
  teacherList () { // 获取所有教练
    return fetch({
      url: '/train/teacher/teacherList'
    })
  },
  classList () {
    return fetch({ // 获取所有课程
      url: '/train/course/simple/list'
    })
  },
  getAddress (params) { // 根据校区id获取上课地点
    return fetch({
      url: '/train/school/address',
      params
    })
  },
  addClassRoom (data, type) { // 新增班级
    return fetch({
      url: '/train/classroom/',
      method: type,
      data
    })
  },
  classRemove (params, options) { // 删除班级
    return fetch({
      url: '/train/classroom/',
      method: 'delete',
      params,
      options
    })
  },
  trainClassInfoShow (params) { // 班级详情
    return fetch({
      url: '/train/classroom/trainClassInfo',
      params
    })
  },
  classScheduleTimeInfo (params) { // 班级详情获取课时数量
    return fetch({
      url: '/train/classroom/classScheduleTimeInfo',
      params
    })
  },
  classScheduleInfo (params) { // 上课记录
    return fetch({
      url: '/train/classroom/classScheduleInfo',
      params
    })
  },
  studentSignUp (params) { // 插入导入报名学员
    return fetch({
      url: '/train/student/class/studentSignUp',
      params
    })
  },
  importStudent (data, options) { // 导入学员
    return fetch({
      url: '/train/student/class/importStudent',
      method: 'post',
      data,
      options
    })
  },
  ckimportStudent (data, options) { // 次课导入学员
    return fetch({
      url: '/train/student/class/times/importStudent',
      method: 'post',
      data,
      options
    })
  },
  coachList (params) { // 获取/查询教练列表
    return fetch({
      url: '/train/teacher/list',
      params
    })
  },
  editCoach (data, options) { // 新增or编辑教练
    return fetch({
      url: '/train/teacher/save',
      method: 'POST',
      data,
      options
    })
  },
  countryList (params) { // 获取国家列表
    return fetch({
      url: '/train/countryList',
      params
    })
  },
  coachCourseDetail (params) { // 获取教练授课详情
    return fetch({
      url: '/train/teacher/courseDetail',
      params
    })
  },
  coachInfo (params) { // 获取教练信息详情
    return fetch({
      url: '/train/teacher/detail',
      params
    })
  },
  studentList (params) { // 获取学员列表
    return fetch({
      url: '/train/student/list',
      params
    })
  },
  studentDetail (params) { // 获取学员详情
    return fetch({
      url: '/train/student/detail',
      params
    })
  },
  studentCourseList (params) { // 获取学员在上课程列表
    return fetch({
      url: '/train/student/class/detail/page',
      params
    })
  },
  studentInfo (params) { // 获取编辑的学员信息
    return fetch({
      url: '/train/student/info',
      params
    })
  },
  editStudent (data, options) { // 编辑学员
    return fetch({
      url: '/train/student/',
      method: 'PUT',
      data,
      options
    })
  },
  addStudent (data, options) { // 批量新增学员
    return fetch({
      url: '/train/student/',
      method: 'POST',
      data,
      options
    })
  },
  studentCourseInfo (params) {
    return fetch({
      url: '/train/student/class/detail',
      params
    })
  },
  studentCourse (params) { // 获取学员上课情况列表
    return fetch({
      url: '/train/student/class/schedule/detail',
      params
    })
  },
  getScheduleOptions (params) { // 获取课程表筛选选项
    return fetch({
      url: '/train/course/schedule/list/condition',
      params
    })
  },
  getSchoolListByProCity (params) { // 根据省市获取校区选项
    return fetch({
      url: '/train/student/schoolListByProCity',
      params
    })
  },
  studentVacate (params) { // 学员请假课时信息
    return fetch({
      url: '/train/student/schedule/leaveList',
      params
    })
  },
  studentLeaveSchedule (params) { // 获取班级的学生课时
    return fetch({
      url: '/train/student/class/leaveSchedule',
      params
    })
  },
  studentLeave (data, options) { // 学生请假
    return fetch({
      url: '/train/student/class/leave',
      method: 'PUT',
      data,
      options
    })
  },
  studentCancelLeaveSchedule (params) { // 获取班级的学生取消请假课时
    return fetch({
      url: '/train/student/class/cancelLeaveSchedule',
      params
    })
  },
  studentCancelLeave (data, options) { // 学生撤销请假
    return fetch({
      url: '/train/student/class/cancelLeave',
      method: 'PUT',
      data,
      options
    })
  },
  studentDelete (data, options) { // 班级删除学员
    return fetch({
      url: `/train/student/class?studentClassId=${data.id}`,
      method: 'DELETE',
      data,
      options
    })
  },
  studentCloseVacate (params) { // 学员撤销请假课时信息
    return fetch({
      url: '/train/student/schedule/cancelLeave',
      params
    })
  },
  studentPutVacate (data, options) { // 提交学员请假
    return fetch({
      url: '/train/student/class/leave',
      method: 'put',
      data,
      options
    })
  },
  studentPutCloseVacate (data, options) { // 提交学员撤销请假
    return fetch({
      url: '/train/student/class/cancelLeave',
      method: 'put',
      data,
      options
    })
  },
  courseTimeCount (params) { // 获取所有课时信息
    return fetch({
      url: '/train/student/count/schedule',
      params
    })
  },
  studentMakeUp (params) { // 获取学员的补课信息
    return fetch({
      url: '/train/student/schedule/makeup',
      params
    })
  },
  courseInfo (params) { // 获取补课时课程的课时信息
    return fetch({
      url: '/train/classroom/courseClassSchedule',
      params
    })
  },
  putMakeup (data, options) { // 提交学员补课
    let query = '?'
    if (options.type === 'GET') { // 获取已补课课时ID
      for (let key in data) {
        query += key + '=' + data[key] + '&'
      }
    }
    return fetch({
      url: '/train/student/class/makeup' + query,
      method: options.type,
      data,
      options
    })
  },
  removeValid (params) {
    return fetch({
      url: '/train/school/removeValidate',
      params
    })
  },
  editValidate (params) {
    return fetch({
      url: '/train/school/editVenuesAddressValidate',
      params
    })
  },
  schoolNameValid (params) {
    return fetch({
      url: '/train/school/schoolNameValidate',
      params
    })
  },
  removeStudent (data, options) { // 删除学员列表中的学员
    return fetch({
      url: `/train/student/?studentId=${data.id}`,
      method: 'DELETE',
      data,
      options
    })
  },
  removeCoach (data, options) { // 删除教练列表中的教练
    return fetch({
      url: `/train/teacher/?teacherId=${data.id}`,
      method: 'DELETE',
      data,
      options
    })
  },
  coachVacate (data, options) { // 教练请假
    return fetch({
      url: '/train/teacher/schedule/leave',
      method: 'POST',
      options,
      data
    })
  },
  coachCourseTime (params) { // 获取教练未请假课时
    return fetch({
      url: '/train/teacher/schedule/list',
      params
    })
  },
  coachLeaveCourseTime (params) { // 获取教练需要撤销请假课时
    return fetch({
      url: '/train/teacher/schedule/cancelList',
      params
    })
  },
  cancelCoachVacate (data, options) { // 教练撤销请假
    return fetch({
      url: '/train/teacher/schedule/cancelLeave',
      method: 'POST',
      options,
      data
    })
  },
  getThisTeacherInfo (params) { // 授权时获取当前教练员
    return fetch({
      url: '/train/teacher/info',
      params
    })
  },
  getStudentHistoryCourse (params) { // 获取学员详情历史课程
    return fetch({
      url: '/train/student/class/history/detail/page',
      params
    })
  },
  studentGetForm (params) {
    return fetch({
      url: '/train/student/signup/getForm',
      params
    })
  },
  classBatcjSign (data, options) {
    return fetch({
      url: '/train/student/batchSignUp',
      method: 'POST',
      options,
      data
    })
  },
  queryStudentInfo (params) {
    return fetch({
      url: '/train/student/query',
      params
    })
  },
  classStudentInfoByCK (params) { // 查询次课班级学员列表
    return fetch({
      url: '/train/student/class/classStudentInfoByCK',
      params
    })
  },
  givenLessons (data, options) { // 添加赠课
    return fetch({
      url: '/train/student/class/donateLesson',
      method: 'POST',
      options,
      data
    })
  },
  saleList (params) {
    if (typeof params.endDate === 'number') {
      let h = new Date(params.endDate).getHours()
      let m = new Date(params.endDate).getMinutes()
      if (h === 0 && m === 0) {
        params.endDate = params.endDate + (3600 * 1000 * 24 - 1000)
      }
    }
    return fetch({
      url: '/train/sale/studentStatisticsBySale',
      params
    })
  },
  // 修改学员状态
  changeStudentState (data, options) {
    return fetch({
      url: '/train/sale/updateStudentStatus',
      method: 'POST',
      data,
      options
    })
  },
  renew (data, options) { // 续费
    return fetch({
      url: '/train/renew/',
      method: 'POST',
      data,
      options
    })
  },
  // 销售列表添加学员
  addStudentFromSale (data, options) {
    return fetch({
      url: '/train/sale/saleStudnet',
      method: 'POST',
      data,
      options
    })
  },
  renewRemind (data, options) { // 续费短信提醒
    return fetch({
      url: '/train/renew/sms',
      method: 'POST',
      data,
      options
    })
  },
  renewNum (params) { // 学员续费提醒总数
    return fetch({
      url: '/train/renew/sms/total',
      params
    })
  },
  queryTimeCourse (params) { // 获取次课类型的数据
    return fetch({
      url: '/train/course/timeCourseList',
      params
    })
  },
  updClassStudentValidity (data) { // 次课设置有效期
    return fetch({
      url: '/train/classroom/updClassStudentValidity',
      method: 'PUT',
      data
    })
  },
  getClassStudentInfoCK (params) { // 次课上课记录
    return fetch({
      url: '/train/classroom/getClassStudentInfoCK',
      params
    })
  },
  unDisposeCourseList (params) { // 获取未销课课时
    return fetch({
      url: '/train/lessons/notConsumed/list',
      params
    })
  },
  disposeCourseList (params) { // 获取已销课课时
    return fetch({
      url: '/train/lessons/consumed/list',
      params
    })
  },
  submitDispose (data, options) { // 提交销课
    return fetch({
      url: '/train/lessons/consume',
      method: 'POST',
      data,
      options
    })
  },
  submitUnDispose (data, options) { // 提交撤销销课
    return fetch({
      url: '/train/lessons/cancelConsume',
      method: 'POST',
      data,
      options
    })
  },
  // 销售数据统计
  saleDataStatistics (params) {
    if (typeof params.endDate === 'number') {
      let h = new Date(params.endDate).getHours()
      let m = new Date(params.endDate).getMinutes()
      if (h === 0 && m === 0) {
        params.endDate = params.endDate + (3600 * 1000 * 24 - 1000)
      }
    }
    return fetch({
      url: '/train/sale/saleDataStatistics',
      params
    })
  },
  // 获取销售人员列表
  getSaleManList (params) {
    return fetch({
      url: '/train/sale/saleByOrg',
      params
    })
  },
  // 获取销售人员下的学员列表
  getStudentList (data, options) {
    return fetch({
      url: `/train/sale/studentBySale?page=${data.page}&rows=${data.rows}`,
      method: 'POST',
      data: JSON.stringify(data),
      options
    })
  },
  // 学员跟进记录
  getStuFollowRerordList (params) {
    return fetch({
      url: '/train/sale/allFollowRecordList',
      params
    })
  },
  // 学员试课记录
  getStuTrialRecordList (params) {
    return fetch({
      url: '/train/sale/allTrialRecordList',
      params
    })
  },
  // 添加学员报名
  signUpFromSale (data, options) {
    return fetch({
      url: '/train/sale/signUpRecord',
      method: 'POST',
      data,
      options
    })
  },
  // 财务对账列表
  financeList (params) {
    if (params.endTime) {
      let h = new Date(params.endTime).getHours()
      let m = new Date(params.endTime).getMinutes()
      if (m === 0 && h === 0) {
        params.endTime = params.endTime + (3600 * 1000 * 24 - 1000)
      }
    }
    return fetch({
      url: '/train/finance/list',
      params
    })
  },
  // 财务数据统计
  financeDataStatistics (params) {
    if (params.endTime) {
      let h = new Date(params.endTime).getHours()
      let m = new Date(params.endTime).getMinutes()
      if (m === 0 && h === 0) {
        params.endTime = params.endTime + (3600 * 1000 * 24 - 1000)
      }
    }
    return fetch({
      url: '/train/finance/statistics',
      params
    })
  },
  // 修改收款记录(到账)
  financeUpdate (data, options) {
    return fetch({
      url: '/train/finance/update',
      method: 'POST',
      data,
      options
    })
  },
  // 学员报名记录
  saleCollection (params) {
    return fetch({
      url: '/train/sale/saleCollectionByStudent',
      params
    })
  },
  // 获取校区选中省市区
  querySelection (data) {
    return fetch({
      url: '/train/school/provinceAndCityList',
      data
    })
  },
  // 根据省市县获取校区
  loadCampus (params) {
    return fetch({
      url: '/train/student/schoolListByProCity',
      params
    })
  },
  studentCkDisposeList (params) { // 学员列表次课列表
    return fetch({
      url: '/train/student/ck/signup/list',
      params
    })
  },
  donateLessonList (params) { // 根据学生ID查看赠课节数
    return fetch({
      url: '/train/student/class/donateLesson/list',
      params
    })
  },
  getCKStudentInfo (params) { // 学生次课销课记录
    return fetch({
      url: '/train/classroom/getCKStudentInfo',
      params
    })
  },
  getStudentTestAge (params) { // 获取测试年龄组信息
    return fetch({
      url: '/train/test/age',
      params
    })
  },
  setStudentTestAge (data) { // 修改学员测试年龄组
    return fetch({
      url: '/train/student/test/age',
      method: 'PUT',
      data
    })
  },
  getStuItemScoreInfo (params) { // 获取学员各项测试成绩
    return fetch({
      url: '/train/test/itemScoreInfo',
      params
    })
  },
  getStuItemScoreRuleInfo (params) { // 获取学员某项测试成绩 编辑 修改
    return fetch({
      url: '/train/test/itemScoreRuleInfo',
      params
    })
  },
  getStuItemScoreStandardInfo (params) {
    return fetch({
      url: '/train/test/scoreStandardInfo',
      params
    })
  },
  saveStuTestScore (data, options) { // 录入学员测试成绩
    return fetch({
      url: '/train/test/inputStudentScore',
      method: 'POST',
      data,
      options
    })
  },
  studentTestList (params) { // 查询学员测试成绩列表
    return fetch({
      url: '/train/test/score/list',
      params
    })
  },
  importStudentTest (data, options) { // 录入学员测试成绩
    return fetch({
      url: '/train/test/score/input',
      method: 'POST',
      data,
      options
    })
  },
  standardRules (params) { // 查看评分标准
    return fetch({
      url: '/train/test/score/standard',
      params
    })
  },
  getTeachTemplateList (params) { // 获取教案模板
    return fetch({
      url: '/train/teach/template/trainCourseTeacherTemplate',
      params
    })
  },
  insertTemplate (data, type) { // 设置&&修改自定义教案模板
    let url = type === 'edit' ? '/train/teach/template/update' : '/train/teach/template/insert'
    let method = type === 'edit' ? 'PUT' : 'POST'
    return fetch({
      url: url,
      method: method,
      data
    })
  },
  getTemData (params) { // 根据模板ID获取模板数据
    return fetch({
      url: '/train/teach/template/trainCourseTeacherTemplateById',
      params
    })
  },
  // 设置教案模板
  setTeachTemplate (data, options) {
    return fetch({
      url: '/train/course/teacherPlanCourseSaveOrUpdate',
      method: 'POST',
      data,
      options
    })
  },
  // 删除教案模板
  delTemplate (data, options) {
    return fetch({
      url: '/train/teach/template/delete?id=' + data.id,
      method: 'DELETE',
      data,
      options
    })
  },
  getScheduleTem (params) { // 根据课时ID获取教案模板
    return fetch({
      url: '/train/teach/template/scheduleId',
      params
    })
  },
  saveBodyData (data, options) {
    return fetch({
      url: '/train/studentBodyData/save',
      method: 'POST',
      data,
      options
    })
  },
  removeBodyData (data, options) {
    return fetch({
      url: `/train/studentBodyData/remove?id=${data.id}&recordDate=${data.recordDate}`,
      method: 'DELETE',
      data,
      options
    })
  },
  getBodyDate (params) {
    return fetch({
      url: '/train/studentBodyData/list',
      params
    })
  },
  uploadCropper (data, options) { // 上传头像
    return fetch({
      url: '/upload/crop/image',
      method: 'POST',
      data,
      options
    })
  },
  freeze (data, options) { // 冻结班级课程
    return fetch({
      url: '/train/freeze/',
      method: 'POST',
      data,
      options
    })
  },
  freezeDetail (params) { // 冻结详情
    return fetch({
      url: '/train/freeze/detail',
      params
    })
  },
  // 保存学员生日
  saveStudentBirthday (data, options) {
    return fetch({
      url: '/train/studentBodyData/birthday',
      method: 'POST',
      data,
      options
    })
  },
  // 学员身体数据类型列表
  getStudentBodyCategory () {
    return fetch({
      url: '/train/studentBodyData/setlist'
    })
  },
  setStudentBodyCategory (data, options) {
    return fetch({
      url: '/train/studentBodyData/set',
      method: 'POST',
      data: data,
      options
    })
  },
  schoolDetails (params) {
    return fetch({
      url: '/train/school/schoolDetailInfo',
      params
    })
  },
  getAdviserList (params) {
    return fetch({
      url: '/train/user/consultant',
      params
    })
  },
  sameClassnotConsumed (params) { // 获取销课课时列表（专综课
    return fetch({
      url: '/train/schedule/notConsumed/list',
      params
    })
  },
  sameClassConsumed (params) { // 获取已销课课时列表（专综课
    return fetch({
      url: '/train/schedule/consumed/list',
      params
    })
  },
  sameConsume (data, options) { // 批量销课-专综课
    return fetch({
      url: '/train/schedule/consume',
      method: 'POST',
      data,
      options
    })
  },
  sameCancelConsume (data, options) { // 撤销销课-专综课
    return fetch({
      url: '/train/schedule/cancelConsume',
      method: 'POST',
      data,
      options
    })
  }
}
